#include <iostream>
#include <fstream>
#include <cstdlib>
#include <cmath>
#include <string>
#include <stdio.h>
#ifdef __cplusplus__
#include <cstdlib>
#else
#include <stdlib.h>
#endif

using namespace std;


/*the remove part
int Remove()
{
  if( remove( "Settings.ini" ) != 0 )
    perror( "Error deleting file" );
  else
    puts( "File successfully deleted" );
  return 0;
}
*/

//the server configuration

int main()
{
  string Owner;
 
  cout << "Please enter your username: ";
    
  cin >> Owner;
  if (system("CLS")) system("clear");
  ofstream myfile;
  myfile.open ("users.ini");
  myfile << "[" << Owner << "]" << "\nGroups=Admins";
  myfile.close();
  int Port;
  int MaxPlayers;
  string Descriptiontwo;
    cout << "Please Enter your server port (default minecraft is 25565): ";

    cin >> Port;
    if (system("CLS")) system("clear");

    cout << "Please enter the maxplayers able to join: ";

    cin >> MaxPlayers;
    if (system("CLS")) system("clear");
  string str;
  cout << "Please enter a server description: " ,getchar();
  getline (cin,str);
  if (system("CLS")) system("clear");
  //cout << "Thank you, " << str << ".\n";

     
    // put into settings.ini
  myfile.open ("settings.ini");
  myfile << "[Server]\n" << "port=" << Port << "\nmaxplayers=" << MaxPlayers << "\nDescription=" << str;
      string MainWorld;
    cout << "What should be the name of your default world?: ";
    cin >> MainWorld;
    if (system("CLS")) system("clear");
    myfile << "\n\n[Worlds]\n" << "DefaultWorld=" << MainWorld;
    char yesNO;

    cout << "Would you like to enable the core plugin?? y/n: ";

    cin >> yesNO;
    if (system("CLS")) system("clear");

    if (yesNO=='y')
    {
        myfile << "\n\n[Plugins]\n" << "Plugin=Core\n" << "Plugin=ChatLog\n";
        cout << "Would you like to enable the /pluginlist command? y/n: ";
        char YESno;
        cin >> YESno;
        if (system("CLS")) system("clear");
        if (YESno =='y')
        {
            myfile << "\n[HelpPlugin]\n" << "ShowPluginNames=1";
        }
        if (YESno=='n')
        { 
            myfile << "\n[HelpPlugin]\n" << "ShowPluginNames=0";
        }
        if (YESno =='Y')
        {
            myfile << "\n[HelpPlugin]\n" << "ShowPluginNames=1";
        }
        if (YESno=='N')
        { 
            myfile << "\n[HelpPlugin]\n" << "ShowPluginNames=0";
        }
        return 0;
    }

    if (yesNO=='n')
    {
        myfile << "\n\n[Plugins]\n" << "Plugin=ChatLog\n";
        return 0;
    }
    if (yesNO=='Y')
    {
        myfile << "\n\n[Plugins]\n" << "Plugin=Core\n" << "Plugin=ChatLog\n";
        cout << "Would you like to enable the /pluginlist command? y/n: ";
        char YESno;
        cin >> YESno;
        if (system("CLS")) system("clear");
        if (YESno =='y')
        {
            myfile << "\n[HelpPlugin]\n" << "ShowPluginNames=1";
        }
        if (YESno=='n')
        { 
            myfile << "\n[HelpPlugin]\n" << "ShowPluginNames=0";
        }
        if (YESno =='Y')
        {
            myfile << "\n[HelpPlugin]\n" << "ShowPluginNames=1";
        }
        if (YESno=='N')
        { 
            myfile << "\n[HelpPlugin]\n" << "ShowPluginNames=0";
        }
        return 0;
    }

    if (yesNO=='N')
    {
        myfile << "\n\n[Plugins]\n" << "Plugin=ChatLog\n";
        return 0;
    }
    if (yesNO < 'n', 'y')
    {
        cout << "Closing...";
        return 0;
    }
    
  return 0;
}


